const{getChatList,getChatMessage} = require("./index.service")
const {send} = require("@/zy-common/utils")

class chatController {
  async getChatList(ctx,next){
    try {
      let result = await getChatList();
      send(ctx,200,'200',"获取聊天列表成功",result)
    } catch (error) {
      ctx.app.emit('error',error,ctx)
    }
  }
  async getChatMessage(ctx,next){
    const {id} = ctx.user;
    const {friendId} = ctx.request.body
    let result = await getChatMessage(String(id),String(friendId))
    send(ctx,200,'200',"获取聊天记录成功",result)
  } catch (error) {
    console.log(error)
    ctx.app.emit('error',error,ctx)
  }
}

module.exports = new chatController()